package com.lunwen.lunwen.services.impl;

import com.lunwen.lunwen.bean.BanJi;
import com.lunwen.lunwen.bean.XueYuan;
import com.lunwen.lunwen.mapper.XueYuanMapper;
import com.lunwen.lunwen.services.XueYuanService;
import org.springframework.stereotype.Service;

import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;

/**
 * (XueYuan)表服务实现类
 *
 * @author makejava
 * @since 2020-07-20 13:22:55
 */
@Service
public class XueYuanServiceImpl implements XueYuanService {

    @Autowired
    private XueYuanMapper xueYuanMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public XueYuan queryById(String id) {
        return this.xueYuanMapper.queryById(id);
    }

    /**
     * 通过名称查询单条数据
     *
     * @param xueyuanmingcheng 名称
     * @return 实例对象
     */
    @Override
    public XueYuan queryByMingCheng(String xueyuanmingcheng) {
        return this.xueYuanMapper.queryByMingCheng(xueyuanmingcheng);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<XueYuan> queryAllByLimit(int offset, int limit) {
        return this.xueYuanMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param xueYuan 实例对象
     * @return 实例对象
     */
    @Override
    public XueYuan insert(XueYuan xueYuan) {
        this.xueYuanMapper.insert(xueYuan);
        return xueYuan;
    }

    /**
     * 修改数据
     *
     * @param xueYuan 实例对象
     * @return 实例对象
     */
    @Override
    public XueYuan update(XueYuan xueYuan) {
        this.xueYuanMapper.update(xueYuan);
        return this.queryById(xueYuan.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String id) {
        return this.xueYuanMapper.deleteById(id) > 0;
    }

    @Override
    public List<XueYuan> queryAll(XueYuan xueYuan) {
        return this.xueYuanMapper.queryAll(xueYuan);
    }
}